package com.scrx.ymg.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.gson.Gson;
import com.scrx.ymg.entity.OrderForm;
import com.scrx.ymg.entity.OtherInfo;
import com.scrx.ymg.entity.OtherMoney;
import com.scrx.ymg.entity.SeckillProduct;
import com.scrx.ymg.service.seckill.ISeckillService;

@Controller
@RequestMapping("/otherAction")
public class OtherAction {
	
	@Autowired
	private ISeckillService kills;
	
	
	/**
	 * 团购商品上下架
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/putawaySeckillProduct",produces = "text/json;charset=UTF-8")
	public String putawaySeckillProduct(SeckillProduct product){
		return kills.putawaySeckillProduct(product);
	}
	/**
	 * 秒杀广告申请发布
	 * @param product
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/applyCheckSeckillProduct",produces = "text/json;charset=UTF-8")
	public String applyCheckSeckillProduct(SeckillProduct product){
		//kills.applyCheckSeckillProduct(product.getId());
		return "作废接口";
	}
	/**
	 * 团购核销
	 * @param product
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/verificationCode",produces = "text/json;charset=UTF-8")
	public String verificationCode(OrderForm order){
		return kills.verificationCode(order);
	}
	/**
	 * 修改异业商家信息
	 * @param info
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/updateOtherInfo",produces = "text/json;charset=UTF-8")
	public String updateOtherInfo(OtherInfo info,String oldPassWord,String newPassWord){
		return kills.updateOtherInfo(info,oldPassWord,newPassWord);
	}
	
	/**
	 * 得到异业商家营业额
	 * @param otherId
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/getOtherMoney",produces = "text/json;charset=UTF-8")
	public String getOtherMoney(int otherId){
		OtherMoney money = kills.getOtherMoney(otherId);
		Gson gson = new Gson();
		return gson.toJson(money);
	}
	
	/**
	 * 审核异业商家
	 * @param other
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/checkOtherInfo",produces = "text/json;charset=UTF-8")
	public String checkOtherInfo(OtherInfo other){		
		return kills.checkOtherInfo(other);
	}
	
	/**
	 * 审核失败删除异业商家
	 * @param other
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/deleteOtherInfo",produces = "text/json;charset=UTF-8")
	public String deleteOtherInfo(OtherInfo other){
		return kills.deleteOtherInfo(other);
	}
	
	/**
	 * 恢复冻结异业商家
	 * @param other
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/updateOtherInfoByStatus",produces = "text/json;charset=UTF-8")
	public String updateOtherInfoByStatus(OtherInfo other){		
		return kills.updateOtherInfoByStatus(other);
	}
	
}
